import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Heand from '../../component/heand';
import { useNavigate } from "react-router-dom";
import { Input, Button } from 'antd';


function Add_newdoor_pcphone() {
  const [address,setAddress]=useState('')
  const [phone,setPhone]=useState('')
  const [e_mail,setE_mail]=useState('')
  const [pc,setPc]=useState('')
   
   const handleNameChangeaddress = (event)=>{
    setAddress(event.target.value)
   }
   const handleNameChangephone = (event)=>{
    setPhone(event.target.value)
   }
   const handleNameChangee_mail = (event)=>{
    setE_mail(event.target.value)
   }
   const handleNameChangepc = (event)=>{
    setPc(event.target.value)
   }
  
   
const handleSubmit= async()=>{
    try {
        const response = await axios.put(`https://r5ctn9z9.lc-cn-n1-shared.com/1.1/classes/pcphone/${'6583b2a49a790104bd7110d4'}`, {
            address:address,
            phone:phone,
            e_mail:e_mail,
            pc:pc
        }, {
            headers: {
                " X-LC-Id": "r5CTN9z96pCW8mI8fx9YxOmw-gzGzoHsz",
                "X-LC-Key": "8gSsl4Sz0ILMiQeMNMA8xQqg",
                'Content-Type': 'application/json'
            }
        }).then((e) => {
            console.log(e.data); // 处理返回的数据
            //   setShowInput(false);

            window.location.reload()

          


            // 更新展示的数据
        })


    } catch (error) {
        console.error(error);
    }
}
  
  return (

    <div className='pushinput'>
      <Heand />

      <form className='pushtj' >
        <div>
          <label htmlFor="name">地址：</label>
          <Input className="xqinp" type="text" id="name" value={address} onChange={handleNameChangeaddress} />
        </div>
       
        <div>
          <label htmlFor="name">联系方式：</label>
          <Input className="xqinp" type="text" id="name" value={phone} onChange={handleNameChangephone} />
        </div>
        <div>
          <label htmlFor="name">邮箱：</label>
          <Input className="xqinp" type="text" id="name" value={e_mail} onChange={handleNameChangee_mail} />
        </div>
        <div>
          <label htmlFor="name">pc端网址：</label>
          <Input className="xqinp" type="text" id="name" value={pc} onChange={handleNameChangepc} />
        </div>
       

        <Button onClick={handleSubmit} >添加商品</Button>
      </form>
    </div>
  )
}

export default Add_newdoor_pcphone;